﻿Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';
//生成标签页
var tab = new Ext.TabPanel({
			region:'center',
			deferredRender:false,
			activeTab:0,
			resizeTabs:true, // turn on tab resizing
			minTabWidth: 115,
			tabWidth:135,
			enableTabScroll:true
		});

Ext.onReady(function(){
   //layout
   var viewport = new Ext.Viewport({
		layout:'border',
		items:[
			new Ext.BoxComponent({
				region:'north',
				el: 'north',
				height:80
			}),new Ext.BoxComponent({
				region:'south',
				el: 'south_div',
				height:22
			}),{
			region:'west',
			id:'west-panel',
			split:true,
			width: 300,
			minSize: 175,
			maxSize: 400,
			margins:'0 0 0 0',
			layout:'accordion',
//			title:'学生管理系统',
			collapsible :true,
			layoutConfig:{
				animate:true
				},
		    items: [
			    {
					title:'功能菜单',
					border:false,
					html:'<div id="tree" style="overflow:auto;width:100%;height:100%"></div>'
					//iconCls:'nav'
			    }]
			},
	        tab//初始标签页
		 ]
	});

    var root=new Ext.tree.TreeNode({
		    id:"root",
		    text:"树的根"
		});

    var a=new Ext.tree.TreeNode({
		id:'a',
		icon:'images/tree_node.gif',
		text:'申请表单管理'
	});


    var a2=new Ext.tree.TreeNode({
		id:'a2',
		icon:'images/tree_node.gif',
		text:'我的请假单',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="myTroubleTicket/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
		
	});

   var a3=new Ext.tree.TreeNode({
		id:'a3',
		icon:'images/tree_node.gif',
		text:'待审申请',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="approvingTroubleTicket/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
		
	});

   var a4=new Ext.tree.TreeNode({
		id:'a4',
		icon:'images/tree_node.gif',
		text:'已审申请',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="approvedTroubleTicket/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
		
	});

   var d=new Ext.tree.TreeNode({
		id:'d',
		icon:'images/tree_node.gif',
		text:'工作流管理'
	});

    var d1=new Ext.tree.TreeNode({
		id:'d1',
		icon:'images/tree_node.gif',
		text:'流程管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="processDefinition/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});		
	
   var e=new Ext.tree.TreeNode({
		id:'e',
		icon:'images/tree_node.gif',
		text:'用户管理'
	});
  
    var e1=new Ext.tree.TreeNode({
		id:'e1',
		icon:'images/tree_node.gif',
		text:'用户管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="user/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});		
    var e2=new Ext.tree.TreeNode({
		id:'e2',
		icon:'images/tree_node.gif',
		text:'学生管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="student/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});
    //------------begin---------------------
    var yrsqb = new Ext.tree.TreeNode({
		id:'yrsqb',
		icon:'images/tree_node.gif',
		text:'用人申请表'
	});
    
    var my_yrsqb=new Ext.tree.TreeNode({
		id:'my_yrsqb',
		icon:'images/tree_node.gif',
		text:'我的单据',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="personnelRequirement/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    
    var wait_yrsqb=new Ext.tree.TreeNode({
		id:'wait_yrsqb',
		icon:'images/tree_node.gif',
		text:'待审单据',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="personnelRequirement/approvingIndex.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    var alread_yrsqb=new Ext.tree.TreeNode({
		id:'alread_yrsqb',
		icon:'images/tree_node.gif',
		text:'已审单据',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="personnelRequirement/approvedIndex.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    
    
    var xzgl = new Ext.tree.TreeNode({
		id:'xzgl',
		icon:'images/tree_node.gif',
		text:'行政管理'
	});
    
    var dept=new Ext.tree.TreeNode({
		id:'dept',
		icon:'images/tree_node.gif',
		text:'部门管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="department/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    var empLevel=new Ext.tree.TreeNode({
		id:'empLevel',
		icon:'images/tree_node.gif',
		text:'角色管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="empLevel/empLevel_index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    
    var empy=new Ext.tree.TreeNode({
		id:'empy',
		icon:'images/tree_node.gif',
		text:'职员管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="employee/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    
   
    var workflowManage=new Ext.tree.TreeNode({
		id:'workflowManage',
		icon:'images/tree_node.gif',
		text:'工作流程管理',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="processDefinition/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});		
  //------------end---------------------
    var g=new Ext.tree.TreeNode({
		id:'g',
		icon:'images/tree_node.gif',
		text:'权限管理',
			listeners:{    
	        'click':function(node, event) {    
	             event.stopEvent();    
	            var n = tab.getComponent(node.id);    
	            if (!n) { //判断是否已经打开该面板    
	                 n = tab.add({    
	                    'id':node.id,    
	                    'title':node.text,    
	                     closable:true,  //通过html载入目标页    
	                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="dept/index.action"></iframe>'   
	                 });    
	             }    
	             tab.setActiveTab(n);    
	         }    
			}
});
	
    var f=new Ext.tree.TreeNode({
		id:'f',
		icon:'images/tree_node.gif',
		text:'文件上传'
	});
	
	  var f1=new Ext.tree.TreeNode({
		id:'f1',
		icon:'images/tree_node.gif',
		text:'上传资料',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="fileUp/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
	  var f2=new Ext.tree.TreeNode({
		id:'f2',
		icon:'images/tree_node.gif',
		text:'上传图片',
		listeners:{    
        'click':function(node, event) {    
            event.stopEvent();    
            var n = tab.getComponent(node.id);    
            if (!n) { //判断是否已经打开该面板    
                 n = tab.add({    
                    'id':node.id,    
                    'title':node.text,    
                     closable:true,  //通过html载入目标页    
                     html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="student/index.action"></iframe>'   
                 });    
             }    
             tab.setActiveTab(n);    
         }    
		}
	});	
    a.appendChild(a2);
    a.appendChild(a3);
    a.appendChild(a4);
    d.appendChild(d1);
    e.appendChild(e1);
    e.appendChild(e2);
    f.appendChild(f1);
    f.appendChild(f2);
 
     
//	root.appendChild(a);
//	root.appendChild(d);
//    root.appendChild(e);
//    root.appendChild(g);
//    root.appendChild(f);
    yrsqb.appendChild(my_yrsqb);
    yrsqb.appendChild(wait_yrsqb);
    yrsqb.appendChild(alread_yrsqb);
    xzgl.appendChild(yrsqb);
    xzgl.appendChild(dept);
    xzgl.appendChild(empy);
    xzgl.appendChild(empLevel);
    xzgl.appendChild(workflowManage);
    
    root.appendChild(xzgl);

	var tree2=new Ext.tree.TreePanel({
		renderTo:"tree",
		root:root,    //对应 根节点
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true
	});
});